home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / DDPLUS71.ZIP / SETUP.ZIP / SDIALOGS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-09  |  7.0 KB  |  256 lines

  1. (****************************************************)
  2. (*   Programming:  Bob Dalton                       *)
  3. (*   Demonstration Program for using Turbo Vision   *)
  4. (*    as a game configuration and setup program     *)
  5. (*    for BBS Doors                                 *)
  6. (****************************************************)
  7. {This unit sets up the individual dialogs and actions which happen
  8.  for your program.  In the below examples I use nothing but radio
  9.  buttons because I feel they are the best for an editor or game
  10.  configuration program. What are radio buttons?  It means only
  11.  ONE button can be selected at anyone time among the choices given}
  12.  
  13. unit SDialogs;
  14.  
  15. interface
  16.  
  17. Uses WorldVar;
  18.  
  19. {To be called by the program they must be listed here}
  20.  
  21. function HowManySoldiers: Word;
  22. function HowManyTanks: Word;
  23. function HowMuchMoney: Word;
  24. function HowManyGenerals: Word;
  25.  
  26. implementation
  27.  
  28. uses Dialogs,   {has TDialog}
  29.      Objects,   {has TRect}
  30.      Views,     {has ofXXXXX constants}
  31.      App;       {has Desktop global variable}
  32.  
  33. {The below function sets up the Turbo Vision dialog and then
  34.  performs an action when the button choice is made}
  35. function HowManySoldiers: Word;
  36. var R    : TRect;
  37.     PDlg : PDialog;
  38.     RB   : PRadioButtons;
  39.     AMask: LongInt;
  40.     Scope: LongInt;
  41.  
  42.  Begin
  43.    R.Assign(17, 1, 57, 16); {Overall size of dialog box}
  44.    {The next line center the text "Maximum Players" between
  45.     the lines at the top of the dialog box}
  46.    PDlg := New(Pdialog, Init(R,'How Many Soldiers?'));
  47.    with PDlg^ do
  48.    begin
  49.     R.Assign(5, 1, 35, 11); {Size of the radio button box}
  50.     RB := New(PRadioButtons, Init(R,
  51.     NewSItem('100',
  52.     NewSItem('150',
  53.     NewSItem('200',
  54.     NewSItem('250',
  55.     NewSItem('300',
  56.     NewSItem('350',
  57.     NewSItem('400',
  58.     NewSItem('450',
  59.     NewSItem('500',
  60.     NewSItem('550',
  61.     nil))))))))))));
  62.     Insert(RB);
  63.     {The next line presets one of the buttons - "0" = First button}
  64.     RB^.Press(3);
  65.     {The next line sets "AMASK" to how many buttons choices there are}
  66.     AMask:=Rb^.EnableMask;
  67.     {The next line is quite handy in that if registered=false then
  68.      the buttons will be greyed out and the user will only be able
  69.      to view them and NOT make any changes}
  70.     IF Registered=False then RB^.SetButtonState(Amask,False);
  71.     R.Assign(7, 12, 19, 14); {Sets button size for next two items}
  72.     Insert(New(PButton, Init(R, 'O~k~', cmOk, bfDefault)));
  73.     R.Move(14, 0);
  74.     Insert(New(PButton, Init(R, '~C~ancel', cmCancel, 0)));
  75.     SelectNext(False);
  76.    end;
  77.   HowManySoldiers := Desktop^.ExecView(PDlg);
  78.   {The next item is also very hand as it gets the number of whatever
  79.    radio button is currently pushed and equates it to "SCOPE". One
  80.    thing to remember though is that button numbers start with zero (0)}
  81.   RB^.GetData(Scope);
  82.   Case Scope of
  83.    0: Glob.soldiers:=100; {If button 0 is pushed then this value is assigned to the record variable}
  84.    1: Glob.soldiers:=150;
  85.    2: Glob.soldiers:=200;
  86.    3: Glob.soldiers:=250;
  87.    4: Glob.soldiers:=300;
  88.    5: Glob.soldiers:=350;
  89.    6: Glob.soldiers:=400;
  90.    7: Glob.soldiers:=450;
  91.    8: Glob.soldiers:=500;
  92.    9: Glob.soldiers:=550;
  93.   End;
  94.   Dispose(PDlg, Done); {Don't forget to do this!}
  95.  
  96.  End;
  97.  
  98.  
  99. function HowManyTanks: Word;
  100. var R    : TRect;
  101.     PDlg : PDialog;
  102.     RB   : PRadioButtons;
  103.     AMask: LongInt;
  104.     Scope: LongInt;
  105.  
  106.  Begin
  107.    R.Assign(17, 1, 57, 16);
  108.    PDlg := New(Pdialog, Init(R,'How Many Tanks?'));
  109.    with PDlg^ do
  110.    begin
  111.     R.Assign(5, 1, 35, 11);
  112.     RB := New(PRadioButtons, Init(R,
  113.     NewSItem('1',
  114.     NewSItem('2',
  115.     NewSItem('3',
  116.     NewSItem('4',
  117.     NewSItem('5',
  118.     NewSItem('6',
  119.     NewSItem('7',
  120.     NewSItem('8',
  121.     NewSItem('9',
  122.     NewSItem('10',
  123.     nil))))))))))));
  124.     Insert(RB);
  125.     RB^.Press(2);
  126.     AMask:=Rb^.EnableMask;
  127.     IF Registered=False then RB^.SetButtonState(Amask,False);
  128.     R.Assign(7, 12, 19, 14);
  129.     Insert(New(PButton, Init(R, 'O~k~', cmOk, bfDefault)));
  130.     R.Move(14, 0);
  131.     Insert(New(PButton, Init(R, '~C~ancel', cmCancel, 0)));
  132.     SelectNext(False);
  133.    end;
  134.   HowManyTanks := Desktop^.ExecView(PDlg);
  135.   RB^.GetData(Scope);           {Get Value from Radio Buttons}
  136.   Case Scope of
  137.    0: Glob.Tanks:=1;
  138.    1: Glob.Tanks:=2;
  139.    2: Glob.Tanks:=3;
  140.    3: Glob.Tanks:=4;
  141.    4: Glob.Tanks:=5;
  142.    5: Glob.Tanks:=6;
  143.    6: Glob.Tanks:=7;
  144.    7: Glob.Tanks:=8;
  145.    8: Glob.Tanks:=9;
  146.    9: Glob.Tanks:=10;
  147.   End;
  148.   Dispose(PDlg, Done);
  149. End;
  150.  
  151. function HowMuchMoney: Word;
  152. var R    : TRect;
  153.     PDlg : PDialog;
  154.     RB   : PRadioButtons;
  155.     AMask: LongInt;
  156.     Scope: LongInt;
  157.  
  158.  Begin
  159.    R.Assign(17, 1, 57, 16);
  160.    PDlg := New(Pdialog, Init(R,'How Much Money?'));
  161.    with PDlg^ do
  162.    begin
  163.     R.Assign(5, 1, 35, 11);
  164.     RB := New(PRadioButtons, Init(R,
  165.     NewSItem('$500',
  166.     NewSItem('$1000',
  167.     NewSItem('$1500',
  168.     NewSItem('$2000',
  169.     NewSItem('$2500',
  170.     NewSItem('$3000',
  171.     NewSItem('$3500',
  172.     NewSItem('$4000',
  173.     NewSItem('$4500',
  174.     NewSItem('$5000',
  175.     nil))))))))))));
  176.     Insert(RB);
  177.     RB^.Press(3);
  178.     AMask:=Rb^.EnableMask;
  179.     IF Registered=False then RB^.SetButtonState(Amask,False);
  180.     R.Assign(7, 12, 19, 14);
  181.     Insert(New(PButton, Init(R, 'O~k~', cmOk, bfDefault)));
  182.     R.Move(14, 0);
  183.     Insert(New(PButton, Init(R, '~C~ancel', cmCancel, 0)));
  184.     SelectNext(False);
  185.    end;
  186.   HowMuchMoney := Desktop^.ExecView(PDlg);
  187.   RB^.GetData(Scope);           {Get Value from Radio Buttons}
  188.   Case Scope of
  189.    0: Glob.Money:=500;
  190.    1: Glob.Money:=1000;
  191.    2: Glob.Money:=1500;
  192.    3: Glob.Money:=2000;
  193.    4: Glob.Money:=2500;
  194.    5: Glob.Money:=3000;
  195.    6: Glob.Money:=3500;
  196.    7: Glob.Money:=4000;
  197.    8: Glob.Money:=4500;
  198.    9: Glob.Money:=5000;
  199.   End;
  200.   Dispose(PDlg, Done);
  201. End;
  202.  
  203.  
  204. function HowManyGenerals: Word;
  205. var R    : TRect;
  206.     PDlg : PDialog;
  207.     RB   : PRadioButtons;
  208.     AMask: LongInt;
  209.     Scope: LongInt;
  210.  
  211.  Begin
  212.    R.Assign(17, 1, 57, 16);
  213.    PDlg := New(Pdialog, Init(R,'How Many Generals?'));
  214.    with PDlg^ do
  215.    begin
  216.     R.Assign(5, 1, 35, 11);
  217.     RB := New(PRadioButtons, Init(R,
  218.     NewSItem('1',
  219.     NewSItem('2',
  220.     NewSItem('3',
  221.     NewSItem('4',
  222.     NewSItem('5',
  223.     NewSItem('6',
  224.     NewSItem('7',
  225.     NewSItem('8',
  226.     NewSItem('9',
  227.     NewSItem('10',
  228.     nil))))))))))));
  229.     Insert(RB);
  230.     RB^.Press(0);
  231.     AMask:=Rb^.EnableMask;
  232.     IF Registered=False then RB^.SetButtonState(Amask,False);
  233.     R.Assign(7, 12, 19, 14);
  234.     Insert(New(PButton, Init(R, 'O~k~', cmOk, bfDefault)));
  235.     R.Move(14, 0);
  236.     Insert(New(PButton, Init(R, '~C~ancel', cmCancel, 0)));
  237.     SelectNext(False);
  238.    end;
  239.   HowManyGenerals := Desktop^.ExecView(PDlg);
  240.   RB^.GetData(Scope);           {Get Value from Radio Buttons}
  241.   Case Scope of
  242.    0: Glob.Generals:=1;
  243.    1: Glob.Generals:=2;
  244.    2: Glob.Generals:=3;
  245.    3: Glob.Generals:=4;
  246.    4: Glob.Generals:=5;
  247.    5: Glob.Generals:=6;
  248.    6: Glob.Generals:=7;
  249.    7: Glob.Generals:=8;
  250.    8: Glob.Generals:=9;
  251.    9: Glob.Generals:=10;
  252.   End;
  253.   Dispose(PDlg, Done);
  254. End;
  255.  
  256. End.